<template>
    <el-col :span="5">
        <el-menu
                class="sider"
                default-active="2"
                @open="handleOpen"
                @close="handleClose"
        >
            <el-submenu index="1">
                <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>用户管理</span>
                </template>
                <el-menu-item-group>

                    <el-menu-item index="1-1" @click="ToUserManagement">用户管理</el-menu-item>

                </el-menu-item-group>
        
            </el-submenu>
            <el-submenu index="2">
                <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>内容管理</span>
                </template>
               
                <el-menu-item index="1-1" @click="handlefm">fm管理</el-menu-item>
          <el-menu-item index="1-2" @click="handleArticle">文章管理</el-menu-item>
          <el-menu-item index="1-3" @click="handleQuestion">答疑管理</el-menu-item> 
          <el-menu-item index="1-4" @click="handlePublic">公告管理</el-menu-item>  
          <el-menu-item index="1-5" @click="handleWel">公共福利管理</el-menu-item>   
            </el-submenu>
            <el-submenu index="3">
                <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>导师管理</span>
                </template>
                <el-menu-item-group>
                    <template slot="title">分组一</template>
                    <el-menu-item index="1-1">选项1</el-menu-item>
                    <el-menu-item index="1-2">选项2</el-menu-item>
                </el-menu-item-group>
                <el-menu-item-group title="分组2">
                    <el-menu-item index="1-3">选项3</el-menu-item>
                </el-menu-item-group>
                <el-submenu index="1-4">
                    <template slot="title">选项4</template>
                    <el-menu-item index="1-4-1">选项1</el-menu-item>
                </el-submenu>
            </el-submenu>
            <el-submenu index="4">
                <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>其他管理</span>
                </template>
                <el-menu-item-group>
                    <template slot="title">分组一</template>
                    <el-menu-item index="1-1">选项1</el-menu-item>
                    <el-menu-item index="1-2">选项2</el-menu-item>
                </el-menu-item-group>
                <el-menu-item-group title="分组2">
                    <el-menu-item index="1-3">选项3</el-menu-item>
                </el-menu-item-group>
                <el-submenu index="1-4">
                    <template slot="title">选项4</template>
                    <el-menu-item index="1-4-1">选项1</el-menu-item>
                </el-submenu>
            </el-submenu>
            <el-submenu index="5">
                <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>课程管理</span>
                </template>
                <el-menu-item index="1-5-1" @click="course">课程</el-menu-item>
                <el-menu-item index="1-5-2" @click="heartmark">心理知识</el-menu-item>
                <el-menu-item index="1-5-3" @click="company">公司管理</el-menu-item>
            </el-submenu>
            <el-submenu index="6">
                <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>心理知识管理</span>
                </template>
                <el-menu-item index="1-6-1" @click="heartKnowledge">心理知识</el-menu-item>
            </el-submenu>
            <el-submenu index="8">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>预约管理</span>
        </template>
        <el-menu-item index="1-8-1" @click="reservation">预约列表</el-menu-item>
      </el-submenu>
    </el-menu>
    </el-col>
</template>


<script>
export default {
methods: {
  handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    handlefm(){
      console.log("fm start");
      this.$router.push("/fm")
    },

    handleQuestion(){
      console.log("question start");
      this.$router.push("/question")
    },

    handlePublic(){
      console.log("public start");
      this.$router.push("/notice")
    },

    handleWel(){
      console.log("wel start");
      this.$router.push("/pubwel")
    },

    handleArticle(){
      console.log("article start");
      this.$router.push("/article")
    },



      handleOpen(key, keyPath) {
          console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
          console.log(key, keyPath);
      },
      handlefm() {
          console.log("fm start");
          if (this.$route.path !== '/fm') {
              this.$router.push("/fm").catch(err => {
                  if (err.name !== 'NavigationDuplicated') {
                      console.error(err); // 处理其他错误
                  }
              });
          }
      },
      course() {
          console.log("my course");
          if (this.$route.path !== '/course') {
              this.$router.push("/course").catch(err => {
                  if (err.name !== 'NavigationDuplicated') {
                      console.error(err); // 处理其他错误
                  }
              });
          }
      },
      ToUserManagement() {
          console.log("my UserManagement");
          if (this.$route.path !== '/UserManagement') {
              this.$router.push("/UserManagement").catch(err => {
                  if (err.name !== 'NavigationDuplicated') {
                      console.error(err); // 处理其他错误
                  }
              });
          }
      },
      heartKnowledge() {
          console.log("my heartKnowledge");
          if (this.$route.path !== '/heartKnowledge') {
              this.$router.push("/heartKnowledge").catch(err => {
                  if (err.name !== 'NavigationDuplicated') {
                      console.error(err); // 处理其他错误
                  }
              });
          }
      },
      heartmark() {
          console.log("my heartmark");
          if (this.$route.path !== '/heartmark') {
              this.$router.push("/heartmark").catch(err => {
                  if (err.name !== 'NavigationDuplicated') {
                      console.error(err); // 处理其他错误
                  }
              });
          }
      },
      reservation() {
  console.log("my reservation");
  if (this.$route.path !== '/reservation') {
    this.$router.push("/reservation").catch(err => {
      if (err.name !== 'NavigationDuplicated') {
        console.error(err); // 处理其他错误
      }
    });
  }
},


company() {
      console.log("my company");
      if (this.$route.path !== '/company') {
          this.$router.push("/company").catch(err => {
              if (err.name !== 'NavigationDuplicated') {
                  console.error(err); // 处理其他错误
              }
        });
      }
    },
  }
}



</script>

<style>
    .sider {
        height: 100vh;
        flex-shrink: 0;
        position: fixed;
    }
</style>